SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO

-- =============================================
-- Author:		BonDo2
-- Create date: 5-10-2012
-- Description:	Get All Members Included in a Thread
-- =============================================
CREATE PROCEDURE [dbo].[GetMembersByThread] 
	-- Add the parameters for the stored procedure here
	@ThreadId int = 0
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	SELECT     vMember.*
	FROM       vMember INNER JOIN
               [Include] ON vMember.Id = [Include].MemberId
    WHERE      [Include].ThreadId = @ThreadId   
END

GO
